public class demo01 {
    //特殊时间
    static int months[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    public static void main(String[] args) {
        int sum=0;
        for (int a = 0; a <= 9; a++) {
            for (int b = 0; b <= 9; b++) {
                if(a==b){
                    continue;
                }
                int year=4;
                int month=0;
                int time=0;
                int nums[]={a,a,a,a};
                for (int i = 0; i < nums.length; i++) {
                    int number=0;
                    nums[i]=b;
                    for (int j = 0; j < nums.length; j++) {
                        number=number*10+nums[j];
                    }
                    month+=check_month(number);
                    time+=check_time(number);
                    nums[i]=a;
                }
                sum+=year*month*time;
            }
        }
        System.out.println(sum);
    }
    public static int check_month(int num){
        int month=num/100;
        int day=num%100;
        if(month<1||month>12){
            return 0;
        }
        if(day<1||day>months[month]){
            return 0;
        }
        return 1;
    }
    public static int check_time(int num){
        int hour=num/100;
        int minute=num%100;
        if(hour<0||hour>23){
            return 0;
        }
        if(minute<0||minute>59){
            return 0;
        }
        return 1;
    }
}
